package com.foryou.system.common.controller;

import com.foryou.system.modules.sys.entity.SysUserEntity;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * Controller公共组件
 *
 * Created by LJX
 * 2017/12/16 0016 下午 9:43
 */
public abstract class AbstractController {
	protected Logger logger = LoggerFactory.getLogger(getClass());

	protected SysUserEntity getUser() {
		return (SysUserEntity) SecurityUtils.getSubject().getPrincipal();
	}

	protected Long getUserId() {
		return getUser().getUserId();
	}

	/**
	 * 会话
	 */
	@Autowired
	private HttpSession session;

	protected HttpServletRequest getRequest() {
		return request;
	}

	/**
	 * 获取当前会话
	 *
	 * @return
	 */
	protected Session getSession() {
		return SecurityUtils.getSubject().getSession();
	}

	/**


	/**
	 * 请求
	 */
	@Autowired
	private HttpServletRequest request;

}
